package com.huangfu.learning.javabase.java.enumeration;

/**
 * Created with IntelliJ IDEA.
 * Author: huangfu.daohui
 * Date: 2018/7/9
 * Time: 19:39
 * Version: 1.0
 * Description:JDK1.6之前的switch语句只支持int,char,enum类型，使用枚举，能让我们的代码可读性更强。
 **/
public class EnumSwitch {
    Signal signal = Signal.GREEN;

    public void change() {
        switch (signal) {
            case GREEN:
                signal = Signal.GREEN;
                break;
            case RED:
                signal = Signal.RED;
                break;
            case YELLOW:
                signal = Signal.YELLOW;
                break;
            default:
                System.out.println("默认。。。");
                break;
        }
    }
}

enum Signal {
    GREEN, YELLOW, RED
}